﻿﻿package test {
	import extremefx.geom.Size;
	import extremefx.ui.Container;
	import extremefx.ui.RectangleComponent;
	import extremefx.ui.UIStage;
	
	import flash.display.Sprite;
	import flash.events.Event;		

	/**
	 * @author Marcelo Volmaro
	 */
	 
	[Frame(factoryClass="extremefx.Preloader")];
	public class AnimatedComponentTest extends Sprite {

		private var _cont:Container;
		private var _rect:RectangleComponent;

		public function main():void {
			UIStage.init(this.stage);
			UIStage.STAGE.addEventListener(Event.RESIZE, resizeStage);
			
			var c:Container = _cont = new Container();
			var r:RectangleComponent = _rect = new RectangleComponent("memo");
			r.setBounds(0, 0, 100, 100); 
			c.add(r);
			
			c.attachToDisplay(UIStage.STAGE);
			resizeStage();
		}
		
		private function resizeStage(event:Event = null):void {
			_cont.size = new Size(stage.stageWidth - 1, stage.stageHeight - 1);
			
			var w:uint = (Math.random() * 100) + 50;
			var h:uint = (Math.random() * 100) + 50;
			
			_rect.animateSize(w, h);
			_rect.animatePosition(stage.stageWidth-w, stage.stageHeight - h);
		}
	}
}
